Skip to content

fix(query): keep the previous result when .suspend() changes key with placeholderData - #3

Open
Moon-DaeSeung wants to merge 2 commits into
mainfrom
fix/suspend-keep-previous-data
Open

Moon-DaeSeung wants to merge 2 commits into
mainfrom
fix/suspend-keep-previous-data

Conversation

@Moon-DaeSeung

Copy link
Copy Markdown
Contributor

Problem

placeholderData: keepPreviousData only worked for .load() and imperative .query(). When a selector .suspend(arg) changed its argument (for example, paging with s.items.suspend({ page: s.page })), the new key had no result yet. prepareSuspend then staged a request and suspended, so the boundary fell back to its skeleton on every page change. The option was ignored on this path.

Fix

  • accessor.ts: readSuspendPlaceholder(key) reports when a not-yet-loaded key is requested over a resource that already shows another key's result and has an effective placeholderData (from the field or the provider defaults). In that case prepareSuspend does not suspend. commitSuspend then loads the key after commit through the normal executeQuery path, which already applies placeholderData. While that request is in flight, the active key is not suspended again.
  • select.ts: for such a key, the selector returns the current result with placeholderData applied, isLoading: false and isFetching: true.
  • Without placeholderData, a new key still suspends exactly as before. First loads, SSR streaming and hydration are unchanged.

Tests

  • New: keepPreviousData keeps the previous result visible instead of suspending. The page change shows no fallback, keeps the old items with isFetching: true, swaps to the new items after the response, and makes no duplicate request.
  • New: without placeholderData a new argument still suspends.
  • vitest run: 38 files, 489 tests pass. tsc -p tsconfig.json and tsc -p tsconfig.type-tests.json pass.

🤖 Generated with Claude Code

Moon-DaeSeung and others added 2 commits October 30, 2026 11:33
… placeholderData

With placeholderData (e.g. keepPreviousData), a selector .suspend(arg) whose
argument changes now keeps the resource's current result visible with
isFetching: true and loads the new key after commit, instead of suspending to
the boundary fallback. Without placeholderData a new key still suspends.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Moon-DaeSeung added a commit to comwit/template that referenced this pull request Oct 30, 2026
List pages change the model page/filter through their actions and dim the
list with the query's isFetching; the queries' placeholderData keeps the
current list visible (with @comwit/state including comwit/state#3).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Moon-DaeSeung added a commit to comwit/template that referenced this pull request Oct 30, 2026
List pages change the model page/filter through their actions and dim the
list with the query's isFetching; the queries' placeholderData keeps the
current list visible (with @comwit/state including comwit/state#3).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Moon-DaeSeung added a commit to comwit/template that referenced this pull request Oct 30, 2026
List pages change the model page/filter through their actions and dim the
list with the query's isFetching; the queries' placeholderData keeps the
current list visible (with @comwit/state including comwit/state#3).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Moon-DaeSeung added a commit to comwit/template that referenced this pull request Oct 30, 2026
List pages change the model page/filter through their actions and dim the
list with the query's isFetching; the queries' placeholderData keeps the
current list visible (with @comwit/state including comwit/state#3).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Moon-DaeSeung added a commit to comwit/template that referenced this pull request Oct 31, 2026
List pages change the model page/filter through their actions and dim the
list with the query's isFetching; the queries' placeholderData keeps the
current list visible (with @comwit/state including comwit/state#3).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Moon-DaeSeung added a commit to comwit/template that referenced this pull request Oct 31, 2026
List pages change the model page/filter through their actions and dim the
list with the query's isFetching; the queries' placeholderData keeps the
current list visible (with @comwit/state including comwit/state#3).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Moon-DaeSeung added a commit to comwit/template that referenced this pull request Nov 2, 2026
List pages change the model page/filter through their actions and dim the
list with the query's isFetching; the queries' placeholderData keeps the
current list visible (with @comwit/state including comwit/state#3).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant